//
//  LoginAndRegisterViewController.m
//  月色:(我)
//
//  Created by 殷殷明静 on 16/9/7.
//  Copyright © 2016年 MJ.Y. All rights reserved.
//
#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT [UIScreen mainScreen].bounds.size.height
#define COLOR_ICON [UIColor colorWithRed:255 / 256.0 green:22 / 256.0 blue:63 / 256.0 alpha:1]
#import "LoginAndRegisterViewController.h"
#import "RegisterViewController.h"
#import "LoginViewController.h"
@interface LoginAndRegisterViewController ()
@property (nonatomic, strong) UIButton *loginBtn;
@property (nonatomic, strong) UIButton *registerBtn;
@property (nonatomic, strong) UILabel *delegateLabel;
@property (nonatomic, strong) UIImageView *yueSeIconImageView;
@property (nonatomic, strong) UIButton *qqBtn;
@property (nonatomic, strong) UIButton *weiXinBbtn;
@property (nonatomic, strong) UIButton *weiBoBbtn;
@property (nonatomic, strong) UIButton *backBtn;
@end

@implementation LoginAndRegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initNavigationLeftButton];
    // 自定义leftBarButton
    self.view.backgroundColor = [UIColor whiteColor];
    // 阅色图标imageView
    [self createYueSeImageView];
    // 登录btn
    [self createLoginButton];
    // 注册
    [self createRegisterButton];
    // 注册即视为同意阅色用户协议
    [self createDelegateLabel];
    // weiXinBtn
    [self createWeiXinBtn];
    // qqBtn
    [self createQQbtn];
    // weiboBtn
    [self createWeiBoBtn];
    
}
- (void)initNavigationLeftButton {
    _backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:_backBtn];
    _backBtn.frame = CGRectMake(20, 20, 15, 15);
    [_backBtn setBackgroundImage:[UIImage imageNamed:@"Icon_chacha"] forState:0];
    [_backBtn addTarget:self action:@selector(backToMyViewController) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_backBtn];
}

// 返回之前页面
- (void)backToMyViewController {
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)createWeiBoBtn {
    _weiBoBbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:_weiBoBbtn];
    _weiBoBbtn.frame = CGRectMake(0, 0, 33, 23);
    _weiBoBbtn.center = CGPointMake(WIDTH / 2 + 58, HEIGHT - 80);
    [_weiBoBbtn setBackgroundImage:[UIImage imageNamed:@"Icon_weibo"] forState:0];
}
- (void)createQQbtn {
    _qqBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:_qqBtn];
    _qqBtn.frame = CGRectMake(0, 0, 27, 23);
    _qqBtn.center = CGPointMake(WIDTH / 2 - 60, HEIGHT - 83);
    [_qqBtn setBackgroundImage:[UIImage imageNamed:@"Icon_qq"] forState:0];
}
- (void)createWeiXinBtn {
    _weiXinBbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:_weiXinBbtn];
    _weiXinBbtn.frame = CGRectMake(0, 0, 50, 40);
    _weiXinBbtn.center = CGPointMake(WIDTH / 2, HEIGHT - 80);
    [_weiXinBbtn setBackgroundImage:[UIImage imageNamed:@"Icon_weixin"] forState:0];
}
- (void)createDelegateLabel {
    _delegateLabel = [[UILabel alloc] init];
    [self.view addSubview:_delegateLabel];
    _delegateLabel.frame = CGRectMake(0, 0, 260, 30);
    _delegateLabel.center = CGPointMake(WIDTH / 2, HEIGHT - 15);
    _delegateLabel.text = @"注册即视为同意阅色用户协议";
    _delegateLabel.font = [UIFont systemFontOfSize:11];
    _delegateLabel.textAlignment = 1;
    _delegateLabel.textColor = [UIColor lightGrayColor];
    _delegateLabel.backgroundColor = [UIColor clearColor];
}
- (void)createRegisterButton {
    _registerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:_registerBtn];
    _registerBtn.frame = CGRectMake(0, 0, 230, 30);
    _registerBtn.center = CGPointMake(WIDTH / 2, HEIGHT / 2 + 20);
    _registerBtn.layer.cornerRadius = 15;
    _registerBtn.backgroundColor = [UIColor clearColor];
    [_registerBtn setTitle:@"注册" forState:0];
    _registerBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    [_registerBtn setTitleColor:COLOR_ICON forState:0];
    _registerBtn.layer.borderWidth = 1;
    _registerBtn.layer.borderColor = COLOR_ICON.CGColor;
    [_registerBtn addTarget:self action:@selector(goToRegisterViewController) forControlEvents:UIControlEventTouchUpInside];
}
// push注册页面
- (void)goToRegisterViewController {
    RegisterViewController *registerVC = [RegisterViewController new];
    [self setHidesBottomBarWhenPushed:YES];
    [self.navigationController pushViewController:registerVC animated:YES];
}
// push登录页面
- (void)goToLoginViewController {
    LoginViewController *loginVC = [LoginViewController new];
    [self setHidesBottomBarWhenPushed:YES];
    [self.navigationController pushViewController:loginVC animated:YES];
}
- (void)createLoginButton {
    _loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:_loginBtn];
    _loginBtn.frame = CGRectMake(0, 0, 230, 30);
    _loginBtn.center = CGPointMake(WIDTH / 2, HEIGHT / 2 - 30);
    _loginBtn.layer.cornerRadius = 15;
    _loginBtn.backgroundColor = COLOR_ICON;
    [_loginBtn setTitle:@"登录" forState:0];
    _loginBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    [_loginBtn setTitleColor:[UIColor whiteColor] forState:0];
    [_loginBtn addTarget:self action:@selector(goToLoginViewController) forControlEvents:UIControlEventTouchUpInside];
}
- (void)createYueSeImageView {
    _yueSeIconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"AppIcon40x40"]];
    [self.view addSubview:_yueSeIconImageView];
    _yueSeIconImageView.center = CGPointMake(WIDTH / 2, 120);
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
//    self.tabBarController.tabBar.hidden = YES;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
